/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-05-14 17:27:22
 * @LastEditors: voanit
 * @LastEditTime: 2022-06-11 16:39:08
 */
import React from 'react'
import './App.scss'
// App.tsx
// 导入路由
import { Router, Route, Redirect } from 'react-router-dom'
// 导入页面组件
import Login from './pages/Login/Login'
import Layout from './pages/Layout/Layout'

import ProfileEdit from '@/pages/Profile/Edit/Index'
import Chat from '@/pages/Profile/Chat/Chat'
import { PrivateRoute } from '@/components/PrivateRoute/PrivateRoute'
import history from '@/utils/history'
import Article from './pages/Article/Article'
import Search from './pages/Search/Search'
import SearchResult from './pages/Search/Result/Result'
import KeepAlive from '@/components/KeepAlive/KeepAlive'
// 配置路由规则
function App() {
  return (
    <Router history={history}>
      <div className="app">
        <Route exact path="/" render={() => <Redirect to="/layout" />} />
        {/* <Route path="/layout">
          <Layout />
        </Route> */}
        <KeepAlive path="/layout"> <Layout /></KeepAlive>
        <Route path="/login">
          <Login />
        </Route>
        {/* <Route path='/profile/edit' component={ProfileEdit}></Route> */}
        <PrivateRoute path="/profile/edit">
          <ProfileEdit />
        </PrivateRoute>
        <PrivateRoute path="/chat">
          <Chat></Chat>
        </PrivateRoute>

        <PrivateRoute path="/article/:id">
          <Article></Article>
        </PrivateRoute>

        <Route exact path="/search">
          <Search></Search>
        </Route>
        <Route path="/search/result" exact component={SearchResult}></Route>
      </div>
    </Router>
  )
}
export default App
